import { useState } from "react";

function SetHooks() {

    function useToggle(){
        const [value,setValue] = useState(false);
        const toggle = () => {
            setValue(!value);
        }
        return{
            value,
            toggle
        }
    }
    const {value,toggle} = useToggle();
    
    return (
        <div>
            {value && <h1>SetHooks</h1>}
            <button onClick={toggle}>{!value ? '打开' : '关闭'}</button>
        </div>
    )
}

export default SetHooks;